#pragma comment(linker, "/STACK:16777216")

#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ull;

#define FOR(i,a,b) for (int i(a); i < (b); i++) 
#define REP(i,n) FOR(i,0,n) 
#define SORT(v) sort((v).begin(),(v).end())
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define CL(a,b) memset(a,b,sizeof(a))
#define pb push_back

char nota[12][3]={"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int n, i, j, k, x;
char s[10000000], t[4];

bool read(){
	gets(s);
	//printf("%s %d\n",s ,  strlen(s));
	
	if(!strcmp(s,"***"))return 0;
	scanf("%d", &n);
	return 1;
}

void process(){
	if(strlen(s)){
	
	for(j=i=0;s[i];i++){
		if((s[i]==' '||s[i]=='\0') && i){
			k=0;
			while(nota[k][0]!=t[0])k++;
			
			if(t[1]=='#'){
				++k;
			}
			else if(t[1]=='b'){
				--k;
			}
			
			if(n<0)x = (12+((k+n)%12))%12;
			else x = (k+n)%12;
			
			printf("%s ", nota[x] );
			
			
			j=0;
			t[0]=t[1]=t[2]='\0';
		}
		else{
			t[j]=s[i];
			j++;
		}
	}
	printf("\n");
	gets(s);
}	
}

int main(){ 
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	while(read())process();
	return 0;
}
